package com.huamao.zh.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.huamao.zh.mapper.BuyplaqueMapper;
import com.huamao.zh.mapper.OrdersMapper;
import com.huamao.zh.mapper.OrdersStockscoreMapper;
import com.huamao.zh.mapper.OrdersStoresMapper;
import com.huamao.zh.mapper.UsersRechargeMapper;
import com.huamao.zh.mapper.UsersUpgradeMapper;
import com.huamao.zh.mapper.WorkorderMapper;
import com.huamao.zh.service.OverdueOrdersDeleteService;

@Service
@Transactional
public class OverdueOrdersDeleteServiceImpl implements OverdueOrdersDeleteService {

	@Autowired
	private OrdersStockscoreMapper ordersStockscoreMapper;

	@Autowired
	private OrdersMapper ordersMapper;

	@Autowired
	private UsersRechargeMapper usersRechargeMapper;

	@Autowired
	private UsersUpgradeMapper usersUpgradeMapper;

	@Autowired
	private BuyplaqueMapper buyplaqueMapper;

	@Autowired
	private WorkorderMapper workorderMapper;

	@Autowired
	private OrdersStoresMapper ordersStoresMapper;

	/**
	 * 功能说明：删除30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	@Override
	public void overdueDeleteOrders() {
		synchronized (this.getClass()) {
			// 删除线上商城超过30天未支付订单
			this.deleteOverOrders();
			// 删除商家购买库存积分超过30天未支付
			this.deleteOrdersStockscore();
			// 删除用户充值超过30天未支付订单
			this.deleteUserRecharge();
			// 删除用户升级角色超过30天未支付订单
			this.deleteUsersUpgrade();
			// 删除购买牌匾超过30天未支付订单
			this.deleteBuyplaque();
			// 删除工单超过30天未支付订单
			this.deleteWorkorder();
			// 删除线下商家超过30天未支付订单
			this.deleteOrdersStores();
		}
	}

	/**
	 * 功能说明：删除线下商家超过30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	public void deleteOrdersStores() {
		// LogUtil.info(LogCodeType.CODE_6019, "删除线下商家超过30天未支付订单" + "开始");
		try {
			ordersStoresMapper.deleteOrdersStores();
		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6019, "删除线下商家超过30天未支付订单" + "结束");
	}

	/**
	 * 功能说明：删除工单超过30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	public void deleteWorkorder() {
		// LogUtil.info(LogCodeType.CODE_6018, "删除工单超过30天未支付订单" + "开始");
		try {
			workorderMapper.deleteWorkorder();
		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6018, "删除工单超过30天未支付订单" + "结束");
	}

	/**
	 * 功能说明：删除购买牌匾超过30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	public void deleteBuyplaque() {
		// LogUtil.info(LogCodeType.CODE_6017, "删除购买牌匾超过30天未支付订单" + "开始");
		try {
			buyplaqueMapper.deleteBuyplaque();
		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6017, "删除购买牌匾超过30天未支付订单" + "结束");
	}

	/**
	 * 功能说明：删除用户升级角色超过30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	public void deleteUsersUpgrade() {
		// LogUtil.info(LogCodeType.CODE_6016, "删除用户升级角色超过30天未支付订单" + "开始");
		try {
			usersUpgradeMapper.deleteUsersUpgrade();
		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6016, "删除用户升级角色超过30天未支付订单" + "结束");
	}

	/**
	 * 功能说明：删除用户充值超过30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	public void deleteUserRecharge() {
		// LogUtil.info(LogCodeType.CODE_6015, "删除用户充值超过30天未支付订单" + "开始");
		try {
			usersRechargeMapper.deleteUserRecharge();
		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6015, "删除用户充值超过30天未支付订单" + "结束");
	}

	/**
	 * 功能说明：删除线上商城超过30天未支付订单 Author：lsx SKDate:2017-11-27
	 */
	public void deleteOverOrders() {
		// LogUtil.info(LogCodeType.CODE_6005, "删除线上商城超过30天未支付订单" + "开始");
		try {
			ordersMapper.deleteOverOrders();
		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6005, "删除线上商城超过30天未支付订单" + "结束");
	}

	/**
	 * 功能说明：删除商家购买库存积分超过30天未支付 Author：lsx SKDate:2017-11-27
	 * 
	 * @return
	 */
	public void deleteOrdersStockscore() {
		// LogUtil.info(LogCodeType.CODE_6004, "删除商家购买库存积分超过30天未支付" + "开始");
		try {

			ordersStockscoreMapper.deleteOrdersStockscore();

		} catch (Exception e) {
			e.printStackTrace();
		}
		// LogUtil.info(LogCodeType.CODE_6004, "删除商家购买库存积分超过30天未支付" + "结束");

	}

}
